package com.ag.zrt.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ag.bean.TbPropose;

public class TbProposeDAO extends com.ag.dao.TbProposeDAO {

	private static final Log log = LogFactory.getLog(TbProposeDAO.class);

	public TbPropose findProposeByEventId(String eventId) {
		log
				.debug("finding TbPropose instance with property: tbEvent.EId , value: "
						+ eventId);
		try {
			String queryString = "from TbPropose as model left join fetch model.tbUserByPViceCommander "
					+ "left join fetch model.tbUserByPTeamLeader left join fetch model.tbUserByPCommander "
					+ "left join fetch model.tbUserDeptByPImplementPlan left join fetch model.tbUserDeptByPAssistDept "
					+ "where model.tbEvent.EId = ?";
			if(getHibernateTemplate().find(queryString, eventId).size() > 0){
			return (TbPropose) getHibernateTemplate().find(queryString, eventId).get(0);
			}else{
				return null;
			}
		} catch (RuntimeException re) {
			log.error("find by property name failed", re);
			throw re;
		}
	}
}